package com.jxw.utils;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

/* loaded from: classes.dex */
public class LinearGradientTextView extends AppCompatTextView {
    private LinearGradient mLinearGradient;
    private Paint mPaint;
    private int mViewWidth;

    public LinearGradientTextView(Context context) {
        super(context);
        this.mViewWidth = 0;
    }

    public LinearGradientTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mViewWidth = 0;
    }

    public LinearGradientTextView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mViewWidth = 0;
    }

    @Override // android.view.View
    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        if (this.mViewWidth == 0) {
            this.mViewWidth = getMeasuredWidth();
            this.mLinearGradient = new LinearGradient(0.0f, 0.0f, getPaint().getTextSize() * getText().length(), 0.0f, new int[]{-16318481, -3980545}, (float[]) null, Shader.TileMode.CLAMP);
            this.mPaint = getPaint();
            this.mPaint.setShader(this.mLinearGradient);
        }
    }

    @Override // android.widget.TextView, android.view.View
    protected void onDraw(Canvas canvas) {
        setGravity(3);
        super.onDraw(canvas);
    }
}
